<template>
  <div>
<h2>等级列表</h2>
<input type="button" value="添加会员等级" @click="addlevel">
<table class="table table-bordered">
<tbody>
  <tr>
    <td>ID</td>
    <td>等级名称</td>
  </tr>
  <tr v-for="item in data.list">
    <td>{{item.Id}}</td>
    <td>{{item.Name}}</td>
  </tr>
</tbody>
</table>
  </div>
</template>

<script setup lang="ts">
import { ref, reactive, onMounted } from 'vue';
import axios from 'axios';
import { useRoute,useRouter } from 'vue-router';
const router=useRouter();

const addlevel=()=>{
  router.push("/addlevel");
}

onMounted(()=>{
  getList();
})

let data:any=reactive({
  list:[]
})

const getList = () => {
    axios({
        method: 'get',
        url: '/api/User/ShowLevel'
    })
        .then((res) => {
            console.log(res);
            data.list = res.data;
        })
        .catch((err) => {
            console.log(err);
        });
}









</script>

<style scoped>

</style>